package com.lancoo.znbkxx.teacher.adapter

import android.annotation.SuppressLint
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.model.data.SchoolPaper
import com.lancoo.znbkxx.teacher.utils.HtmlUtils
import kotlinx.android.synthetic.main.item_school_paper.view.*
import kotlinx.android.synthetic.main.item_school_paper.view.tv_effective
import kotlinx.android.synthetic.main.item_school_paper.view.tv_klg
import java.math.BigDecimal


/**
 *@author Admin
 *@date 2021/2/5
 *
 */
class SchoolPaperListAdapter(data: MutableList<SchoolPaper>) :
        BaseQuickAdapter<SchoolPaper, BaseViewHolder>(data) {
    init {
        mLayoutResId = R.layout.item_school_paper
    }

    @SuppressLint("SimpleDateFormat", "SetTextI18n")
    override fun convert(helper: BaseViewHolder, item: SchoolPaper?) {
        helper.addOnClickListener(R.id.tv_publish)
        with(helper.itemView) {
            tv_paper_name.text = item!!.PaperName
            if (item.ZsdExamples.isEmpty()) {
                tv_klg.text = "核心考点：--"
            } else {
                tv_klg.text = HtmlUtils.setText("核心考点：${item.ZsdExamples.subList(0, 2)
                        .joinToString(
                                "、")}...（共<font color='#ff9900'>${item.ImportantZsdCount}</font>个）")
            }
            tv_klg_rate.text = HtmlUtils.setText(
                    "知识点覆盖率：<font color='#00afff'>${item.PaperKnowledgeRate}%</font>")
            tv_effective.text = HtmlUtils.setText(
                    "有效度：<font color='#ff9900'>${item.PaperEffective}%</font>")
            tv_matchrate.text = HtmlUtils.setText(
                    "匹配度：<font color='#1ab600'>${item.PaperMatchRate}%</font>")
            tv_full_score.text = HtmlUtils.setText(
                    "满分：<b><font color='#333333'>${BigDecimal(item.FullScore).stripTrailingZeros()
                            .toPlainString()}分</font></b>")
        }
    }
}